<script setup>
import { ref } from 'vue'
import { getinboundListByOrderIdService } from '@/api/supplierManage'
import { usePurchaserStore } from '@/stores'
import { useRouter } from 'vue-router'
const order = ref([])
const loading = ref(false)
const purchaserStore = usePurchaserStore()
const router = useRouter()

getinboundList()

const getinboundList = async () => {
  order.value = purchaserStore.order
  loading.value = true
  const res = await getinboundListByOrderIdService(purchaserStore.order.orderId)
  order.value.inbounds = res.data.data
  loading.value = false
}

const back = () => {
  router.push('/purchaser/purchaseManage')
}
</script>

<template>
  <page-container title="采购订单详情">
    <template #extra>
      <el-button @click="back">返回</el-button>
    </template>

    <el-descriptions title="">
      <el-descriptions-item label="订单号">{{
        order.orderId
      }}</el-descriptions-item>
      <el-descriptions-item label="供应商名称">{{
        order.supplierName
      }}</el-descriptions-item>
      <el-descriptions-item label="联系人名称">{{
        order.contactName
      }}</el-descriptions-item>
      <el-descriptions-item label="联系人电话">{{
        order.contact_phone
      }}</el-descriptions-item>
      <el-descriptions-item label="供应商地址">{{
        order.address
      }}</el-descriptions-item>
      <el-descriptions-item label="产品名称">{{
        order.productName
      }}</el-descriptions-item>
      <el-descriptions-item label="产品分类">{{
        order.categoryName
      }}</el-descriptions-item>
      <el-descriptions-item label="数量">{{
        order.quantity
      }}</el-descriptions-item>
      <el-descriptions-item label="采购单价">{{
        order.unitPrice
      }}</el-descriptions-item>
      <el-descriptions-item label="采购总额">{{
        order.totalAmount
      }}</el-descriptions-item>
      <el-descriptions-item label="采购日期">{{
        order.orderDate
      }}</el-descriptions-item>
      <el-descriptions-item label="订单状态">{{
        order.status
      }}</el-descriptions-item>
    </el-descriptions>

    <el-table v-loading="loading" :data="supplier.products" style="width: 100%">
      <el-table-column type="index" label="序号" width="100"></el-table-column>
      <el-table-column prop="warehouseName" label="入库名称"></el-table-column>
      <el-table-column prop="quantity" label="入库数量"></el-table-column>
      <el-table-column prop="receivedDate" label="入库日期"></el-table-column>
      <el-table-column prop="checkedBy" label="负责人"></el-table-column>
      <el-table-column prop="state" label="入库状态"></el-table-column>

      <template #empty>
        <el-empty description="服务器出错"></el-empty>
      </template>
    </el-table>
  </page-container>
</template>

<style lang="scss" scoped></style>
